<?php
	if(ICL_LANGUAGE_CODE == 'vi'){
		$action_url = get_bloginfo('url').'building/';
	}else{
		$action_url = get_bloginfo('url').'/building/';
	}
?>
<form  method="get" class="search-fm" action="<?php echo $action_url;?>" >
	<label for="s"><?php _e('Keyword:','building')?></label>
	<input class="ipt-box" type="text" name="s" id="text_keywords" value="<?php echo get_search_query();?>">
    <label><?php _e('Search:','building')?></label>
	<div class="wrap-box">
		<span class="check-box check-ipt">
			<?php 
				$checked1 = '';
				$checked2 = '';
				if(isset($_GET['type'])){					
					$v1 = __('For rent','building');
					$v2 = __('For sale','building');
					if(in_array($v1,$_GET['type']))
						$checked1 = ' checked="checked" ';
					if(in_array($v2,$_GET['type']))
						$checked2 = ' checked="checked" ';	
				}
			?>
			<input type="checkbox"<?php echo $checked1;?> id="search_type" name="type[]" value="<?php _e('For rent','building');?>"><?php _e('For rent','building');?>
			<input type="checkbox"<?php echo $checked2;?> id="search_type" name="type[]" value="<?php _e('For sale','building');?>"><?php _e('For sale','building');?>
		</span>
	</div>
    <label><?php _e('Type:','building')?></label>
	<div class="wrap-box">
		<?php
			$taxonomies = 'building-type';
			$args  = array('hide_empty'=>false);
			$terms = get_terms( $taxonomies, $args ) ;
			$i = 0;			
			$arrTerm = array();
			if(isset($_GET['term_id'])) $arrTerm = $_GET['term_id'];
			foreach($terms as $term){				
				if( $term->parent == 0){
					$i++;
					echo '<span class="check-box">';
					echo '<input type="checkbox" id="search_term" name="term_id[]" value="'.$term->term_id.'"';
					if(in_array($term->term_id,$arrTerm)) echo ' checked="checked" ';
					echo '>';
					echo $term->name;
					echo '</span><br/>';					
				}
			}
		?>
	</div>
	<label><?php _e('Location:','building')?></label>
	<div class="z-index z-index-10">
		<select class="sel-box select-jquery" name="location">
			<option value=""><?php _e('All Location','building')?></option>
			<?php
				$location = getLocation();			
				$arrLocation = array();
				if(isset($_GET['location'])){ $arrLocation = array($_GET['location']); }
				$i = 0;
				foreach($location as $loc){							
					echo '<option value="'.$loc.'"';
					if( in_array( $loc , $arrLocation)) echo ' selected="selected"';
					echo '>'.$loc.'</option>';				
					$i++;
				}
			?>
		</select>
	</div>
	
	<label><?php _e('Bedroom:','building')?></label>
	<div class="z-index z-index-9">
		<select class="sel-box select-jquery" name="bedroom">
			<option value="">All</option>
			<?php
				$bedroom = getBedRoom();
				$arrBedRoom = array();
				if(isset($_GET['bedroom'])){ $arrLocation = array($_GET['bedroom']); }
				foreach($bedroom as $rom){
					echo '<option '.((in_array($rom,$arrLocation)) ? ' selected="selectes"' : '').' value="'.$rom.'">'.$rom.'</option>';
				}
			?>
		</select>
	</div>
	
	<label><?php _e('Agent Name:','building')?></label>
	<div class="z-index z-index-8" name="author">
		<select class="sel-box select-jquery">
			<option value="">All</option>
			<?php
				$blogusers = get_users('orderby=nicename');
				$arrAuthor = array();
				if(isset($_GET['author'])){ $arrAuthor = array($_GET['author']); }
				foreach ($blogusers as $user) {
					echo '<option'.((in_array($user->ID,$arrAuthor)) ? ' selected="selectes"' : '').' value="'.$user->ID.'">'.$user->display_name.'</option>';					
				}
			?>
		</select>
	</div>
	<p class="action-s">
		<input type="submit" id="searchsubmit" class="btn-submit" value="<?php echo esc_attr__( 'Search' )?>" />
	</p>    
</form>